﻿package com.controller
{
	import com.Model.vo.WomanVo;
	import com.Model.WomanProxy;
	import com.utils.DebugTrace;
	import com.view.ApplicationMediator;
	import com.view.BgMediator;
	import com.view.ClothMenuMediator;
	import com.view.MouseMediator;
	import com.view.PaintMenuMediator;
	import com.view.WomanMediator;
	import flash.display.MovieClip;
	import flash.display.Stage;
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	public class StartupCommand extends SimpleCommand implements ICommand
	{
		public function StartupCommand()
		{
			super();
		}
		/**
		 * 这里先将游戏所需要的一些Proxy和Mediator注册
		 * @param	notification
		 */
		override public function execute(notification:INotification):void{
			//DebugTrace.dtrace("code info StartupCommand.as:一切从这里开始了。");
			
			regApplicationMediator(notification.getBody() as Stage);
			regBg();
			regWoman();
			regPaintMenu();
			regClothMenu();
			regMouse();
			sendNotification(ApplicationFacade.OVERSTARTUP);
		}
		private function regApplicationMediator(stage:Stage):void {
			var obj:Object = new Object();
			obj.stage = stage;
			facade.registerMediator(new ApplicationMediator(ApplicationMediator.NAME, obj));
		}
		private function regBg():void {
			var bg:MovieClip = new BgMc();
			var obj:Object = new Object();
			obj.bg = bg;
			facade.registerMediator(new BgMediator(BgMediator.NAME, obj));
		}
		private function regWoman():void {
			var womamMc:MovieClip = new WomanMc();
			var obj:Object = new Object();
			obj.womanMc = womamMc;
			facade.registerProxy(new WomanProxy(WomanProxy.NAME, new WomanVo()));
			facade.registerMediator(new WomanMediator(WomanMediator.NAME,obj));
		}
		private function regPaintMenu():void {
			var paintMenuMc:MovieClip = new PaintMenuMc();
			var obj:Object = { };
			obj.paintMenuMc = paintMenuMc;
			facade.registerMediator(new PaintMenuMediator(PaintMenuMediator.NAME, obj));
		}
		private function regClothMenu():void {
			var clothMenuMc:MovieClip = new ClothMenuMc();
			var obj:Object = { };
			obj.clothMenuMc = clothMenuMc;
			facade.registerMediator(new ClothMenuMediator(ClothMenuMediator.NAME, obj));
		}
		private function regMouse():void {
			var mouseHolder:MovieClip = new MovieClip();
			var obj:Object = { } ;
			obj.mouseHolder = mouseHolder;
			facade.registerMediator(new MouseMediator(MouseMediator.NAME, obj));
		}
	}
}